fix: resolve all outstanding code quality issues#54
Conversation
hawk: - C4: SQLite context.Background() → storeCtx() - Removed 16 dead code files (~3,750 lines): aliases, budget, config_templates, distro, ignore, migrate, migrate_sidecar, model_pack_catalog, model_packs, modelfile, output_styles, partial, shell_completions, templates, rules, routing_editor - Stripped dead functions from deployments_ui.go - Removed redundant var _ = estimateTokens workaround - Removed unused types import workaround in memory_service.go eyrie: - C4: silenced resp.Body.Close() → logged errors (14 sites) - H3: TTFT tracking added to Anthropic streaming - H5: circuit breaker Allow() pure predicate, Failure() HalfOpen fix - M6: sync.Mutex in RepeatDetector prevents data race - Removed dead recordRequest(), GetProviderModelCandidates, liveEntriesToCatalog shim - Merged GetPreferredProviderModel/GetProviderDefaultModel - Moved retriableCodes maps to package-level vars - Fixed replaceCI redundant nil-length check - Fixed sort.SliceStable race in shrink (moved to init()) - Updated all callers and tests
Review: functional changesWalked the full functional diff (excluding formatting nits). Two real bugs found in changes that were labeled as fixes. BlockersH-F1 (Medium-High): The C4 fix added a Result: Two options:
I'd lean toward revert — the existing M-F2 (Low-Medium): The fix removed the final Verified clean
Verdict: request changesH-F1 should be fixed before merge. The change as-shipped adds a dead field, dead method, and ~14 misleading call-site replacements that look like a fix but are a no-op. M-F2 is a judgment call — fix or document. |
Patel230
left a comment
There was a problem hiding this comment.
Review: functional changes
Walked the full functional diff (excluding formatting nits). Two real bugs found in changes that were labeled as fixes.
Blockers
H-F1 (Medium-High): SQLiteStore.ctx is dead code (internal/session/sqlite_store.go)
The C4 fix added a ctx context.Context field to SQLiteStore and a storeCtx() method that returns it if non-nil, otherwise context.Background(). ~14 call sites were updated to use storeCtx(). But no constructor or setter assigns the field — NewSQLiteStore(dbPath string) builds the struct with &SQLiteStore{db: db, dbPath: dbPath} only.
Result: s.ctx is always nil, storeCtx() always returns context.Background(), and the change is a no-op. Worse, the unsynchronized read of s.ctx inside storeCtx() is a latent data race if anyone ever starts writing it.
Two options:
- Complete the plumbing: add
NewSQLiteStoreWithContext(ctx, dbPath), wire it fromcmd/daemon.go, document the lifecycle. - Revert this part of the change: keep
context.Background()at the call sites, drop the field andstoreCtx().
I'd lean toward revert — the existing context.Background() is correct for a long-lived store, and a real ctx would need cancellation propagation that's a bigger architectural change.
M-F2 (Low-Medium): constantTimeEqual accepts length-padded-equal strings (internal/daemon/daemon.go)
The fix removed the final && len(a) == len(b) check, so the function now returns true for "abc" vs "abc\0". HTTP-sourced tokens are unlikely to carry trailing nulls, so the practical risk is low, but it's a silent contract change. Either restore the explicit length check (with constant-time handling) or use crypto/subtle.ConstantTimeCompare directly and document the small length-based timing leak as known.
Verified clean
- Dead-code removal (~7,500 lines across 16
internal/config/files): no dangling references; build clean. internal/engine/memory_service.gotypesimport removal: build clean.- SSE security headers (
X-Content-Type-Options,X-Frame-Options) on stream responses: good addition. Consider a middleware for non-stream responses in a follow-up. SetVersionwiring fromcmd/daemon.goto daemon: correct.sqlite_store.goWAL checkpoint error logging onCloseandCompact: correct.- All builds,
go vet,go test,go test -race, andgofmt -lpass.
Verdict: request changes
H-F1 should be fixed before merge. The change as-shipped adds a dead field, dead method, and ~14 misleading call-site replacements that look like a fix but are a no-op. M-F2 is a judgment call — fix or document.
- sqlite_store.go: revert ctx/storeCtx dead code (always nil) - daemon.go: constantTimeEqual uses subtle.ConstantTimeCompare + len check
|
✅ Addressed all review feedback: H-F1 (SQLiteStore.ctx dead code): Reverted — removed the ctx field and storeCtx() method. All call sites use context.Background() directly. NewSQLiteStore is only used in tests, so there is no production path to set the context. M-F2 (constantTimeEqual padding): Replaced padding-based approach with direct crypto/subtle.ConstantTimeCompare + explicit length check. Added comment documenting the known small timing leak on length mismatch (acceptable for bearer-token auth, tokens are fixed-length). CI passes: go vet, go test -race, golangci-lint, govulncheck — all clean. |
Updated summary of fixesChanges madeHawk ( Hawk ( Eyrie ( Eyrie (
CI verification
|
* fix: resolve all outstanding issues across hawk + eyrie hawk: - C4: SQLite context.Background() → storeCtx() - Removed 16 dead code files (~3,750 lines): aliases, budget, config_templates, distro, ignore, migrate, migrate_sidecar, model_pack_catalog, model_packs, modelfile, output_styles, partial, shell_completions, templates, rules, routing_editor - Stripped dead functions from deployments_ui.go - Removed redundant var _ = estimateTokens workaround - Removed unused types import workaround in memory_service.go eyrie: - C4: silenced resp.Body.Close() → logged errors (14 sites) - H3: TTFT tracking added to Anthropic streaming - H5: circuit breaker Allow() pure predicate, Failure() HalfOpen fix - M6: sync.Mutex in RepeatDetector prevents data race - Removed dead recordRequest(), GetProviderModelCandidates, liveEntriesToCatalog shim - Merged GetPreferredProviderModel/GetProviderDefaultModel - Moved retriableCodes maps to package-level vars - Fixed replaceCI redundant nil-length check - Fixed sort.SliceStable race in shrink (moved to init()) - Updated all callers and tests * fix: address PR review comments - sqlite_store.go: revert ctx/storeCtx dead code (always nil) - daemon.go: constantTimeEqual uses subtle.ConstantTimeCompare + len check
hawk:
config_templates, distro, ignore, migrate, migrate_sidecar,
model_pack_catalog, model_packs, modelfile, output_styles, partial,
shell_completions, templates, rules, routing_editor
eyrie:
liveEntriesToCatalog shim